package org.springframework.boot.web.servlet.server;

import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.MimeMappings;
import org.springframework.boot.web.server.WebServerFactory;
import org.springframework.boot.web.servlet.ServletContextInitializer;

import javax.servlet.ServletContext;
import java.io.File;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Locale;
import java.util.Map;

/**
 * @author chenkh
 * @time 2020/11/23 15:39
 */
public interface ConfigurableServletWebServerFactory extends ConfigurableWebServerFactory, ServletWebServerFactory {
    /**
     * Sets the context path for the web server. The context should start with a "/"
     * character but not end with a "/" character. The default context path can be
     * specified using an empty string.
     * @param contextPath the contextPath to set
     */
    void setContextPath(String contextPath);

    /**
     * Sets the display name of the application deployed in the web server.
     * @param displayName the displayName to set
     * @since 1.3.0
     */
    void setDisplayName(String displayName);

    /**
     * Sets the configuration that will be applied to the container's HTTP session
     * support.
     * @param session the session configuration
     */
    void setSession(Session session);

    /**
     * Set if the DefaultServlet should be registered. Defaults to {@code true} so that
     * files from the {@link #setDocumentRoot(File) document root} will be served.
     * @param registerDefaultServlet if the default servlet should be registered
     */
    void setRegisterDefaultServlet(boolean registerDefaultServlet);

    /**
     * Sets the mime-type mappings.
     * @param mimeMappings the mime type mappings (defaults to
     * {@link MimeMappings#DEFAULT})
     */
    void setMimeMappings(MimeMappings mimeMappings);

    /**
     * Sets the document root directory which will be used by the web context to serve
     * static files.
     * @param documentRoot the document root or {@code null} if not required
     */
    void setDocumentRoot(File documentRoot);

    /**
     * Sets {@link ServletContextInitializer} that should be applied in addition to
     * parameters. This method will replace any previously set or added initializers.
     * @param initializers the initializers to set
     * @see #addInitializers
     */
    void setInitializers(List<? extends ServletContextInitializer> initializers);

    /**
     * Add {@link ServletContextInitializer}s to those that should be applied in addition
     * parameters.
     * @param initializers the initializers to add
     * @see #setInitializers
     */
    void addInitializers(ServletContextInitializer... initializers);

    /**
     * Sets the configuration that will be applied to the server's JSP servlet.
     * @param jsp the JSP servlet configuration
     */
    void setJsp(Jsp jsp);

    /**
     * Sets the Locale to Charset mappings.
     * @param localeCharsetMappings the Locale to Charset mappings
     */
    void setLocaleCharsetMappings(Map<Locale, Charset> localeCharsetMappings);

    /**
     * Sets the init parameters that are applied to the container's
     * {@link ServletContext}.
     * @param initParameters the init parameters
     */
    void setInitParameters(Map<String, String> initParameters);

}
